package cn.amarone.scaffold.entity;

import cn.amarone.scaffold.entity.dict.StatusEnum;
import com.mybatisflex.annotation.*;
import com.mybatisflex.core.keygen.KeyGenerators;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author Amarone
 * @version 1.0
 * @description:
 * @date 2023/7/31 14:08
 */
@Getter
@Setter
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(value = "sys_menu", camelToUnderline = true)
public class SysMenu implements Serializable {

    @Id(keyType = KeyType.Auto, value = KeyGenerators.snowFlakeId)
    @Schema(description = "菜单ID", example = "1")
    private Long id;

    @Schema(description = "父级菜单ID", example = "1")
    private Long parentId;

    @Schema(description = "菜单名称", example = "用户管理")
    private String menuName;

    @Schema(description = "icon", example = "19365410929")
    private String icon;

    @Schema(description = "sort", example = "1")
    private String sort;

    @Schema(description = "组件路径", example = "1")
    private String elementPath;

    @Schema(description = "启用标志")
    private StatusEnum status;
    @Schema(description = "创建日期")
    @Column(onInsertValue = "now()")
    private Date createTime;
    @Schema(description = "创建者")
    private Long createBy;
    @Schema(description = "修改日期")
    @Column(onUpdateValue = "now()")
    private Date updateTime;
    @Schema(description = "修改者")
    private Long updateBy;
    @Schema(description = "删除标记")
    @Column(isLogicDelete = true)
    private Integer deleteFlag;

    @RelationOneToMany(selfField = "id", targetField = "parentId")
    @Column(ignore = true)
    private List<SysMenu> children;
}
